/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package coalescent.cef.command;

import cef.command.EvtImpl_Direct;
import coalescent.cef.event.RunRecursionEvent;
import coalescent.data.meta.MetaInf_AC;
import coalescent.data.meta.MetaInf_Mngr;
import coalescent.model.PopGenModel;
import coalescent.recursion.RecursionListener;
import coalescent.statistic.AC;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Susanta Tewari
 * @version version
 * @history Created on 11/22/13.
 * @since since
 */
public class RunRecursionEventImpl_Direct<L extends RecursionListener> extends EvtImpl_Direct
        implements RunRecursionEvent<L> {

    private final PopGenModel model;
    private final AC config;
    private final List<L> comps = new ArrayList<>();

    public RunRecursionEventImpl_Direct(PopGenModel model, AC config, L... comps) {

        this.model  = model;
        this.config = config;

        for (L comp : comps) {
            this.comps.add(comp);
        }
    }

    @Override
    public PopGenModel getModel() {
        return model;
    }

    @Override
    public AC getStatistic() {
        return config;
    }

    @Override
    public MetaInf_Mngr getMetaInf() {

        return new MetaInf_Mngr() {

            @Override
            public boolean isActive() {
                return false;
            }
            @Override
            public boolean hasInfo() {
                return false;
            }
            @Override
            public MetaInf_AC getDefault() {
                return null;
            }
            @Override
            public MetaInf_AC load() {
                return null;
            }
            @Override
            public void store(MetaInf_AC metaInf_ac) {}
        };
    }

    @Override
    public List<L> getListeners() {
        return comps;
    }

    public static class DEFAULT extends RunRecursionEventImpl_Direct<RecursionListener>
            implements RunRecursionEvent.DEFAULT {

        public DEFAULT(PopGenModel model, AC config, RecursionListener... comps) {
            super(model, config, comps);
        }
    }
}
